package com.ruoyi.aslife.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aslife.domain.Loginlog;
import com.ruoyi.aslife.service.ILoginlogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 登入日志管理Controller
 * 
 * @author ruoyi
 * @date 2022-12-01
 */
@RestController
@RequestMapping("/system/loginlog")
public class LoginlogController extends BaseController
{
    @Autowired
    private ILoginlogService loginlogService;

    /**
     * 查询登入日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(Loginlog loginlog)
    {
        startPage();
        List<Loginlog> list = loginlogService.selectLoginlogList(loginlog);
        return getDataTable(list);
    }

    /**
     * 导出登入日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:export')")
    @Log(title = "登入日志管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Loginlog loginlog)
    {
        List<Loginlog> list = loginlogService.selectLoginlogList(loginlog);
        ExcelUtil<Loginlog> util = new ExcelUtil<Loginlog>(Loginlog.class);
        util.exportExcel(response, list, "登入日志管理数据");
    }

    /**
     * 获取登入日志管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:query')")
    @GetMapping(value = "/{lid}")
    public AjaxResult getInfo(@PathVariable("lid") Long lid)
    {
        return success(loginlogService.selectLoginlogByLid(lid));
    }

    /**
     * 新增登入日志管理
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:add')")
    @Log(title = "登入日志管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Loginlog loginlog)
    {
        return toAjax(loginlogService.insertLoginlog(loginlog));
    }

    /**
     * 修改登入日志管理
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:edit')")
    @Log(title = "登入日志管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Loginlog loginlog)
    {
        return toAjax(loginlogService.updateLoginlog(loginlog));
    }

    /**
     * 删除登入日志管理
     */
    @PreAuthorize("@ss.hasPermi('system:loginlog:remove')")
    @Log(title = "登入日志管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lids}")
    public AjaxResult remove(@PathVariable Long[] lids)
    {
        return toAjax(loginlogService.deleteLoginlogByLids(lids));
    }
}
